<include file="Public:head" title='网址详情' />
<script src="__PUBLIC__/js/other/validate.js"></script>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
        <include file="Public:left" />
        <div class="main-content">
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li><i class="icon-home home-icon"></i><a href="__APP__/{$Think.MODULE_NAME}">首页</a></li>
                    <li><a href="{:U('Modals/lists')}">网址管理</a></li>
                    <li class="active">网址列表</li>
                </ul>
            </div>
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="row">
                            <div class="col-xs-12">
                                <h3 class="header smaller lighter blue">网址{$Think.get.id|getPageType}</h3>
                                <form action="{:U('Sites/detail_post')}" method="POST" id="form"  enctype="multipart/form-data" >
                                    <table class="table table_detail">
                                        <tbody>
                                            <tr>
                                                <td class="td_left">名称:</td>
                                                <td> 
                                                    <input name="name" type="text" class="common_txt" id="name"  value="{$detail.name}" maxlength="150" autocomplete="off" style='width:456px'/>
                                                    <a href='{$detail.source}' target="_blank">{$detail.source}</a>
                                                </td>
                                            </tr>
                                            <tr id="logo_area_tr">
                                                <td class="td_left">上传图片</td>
                                                <td>
                                                    <a class="btn btn-app btn-purple btn-sm" id="logo_upload_btn" href="javascript:;">
                                                        <i class="icon-cloud-upload bigger-200"></i>
                                                        Upload
                                                    </a>
                                                    <div id="logo_upload_area" style="position: relative;">
                                                        <if condition="$detail.id gt 0">
                                                            <img src="{$id|getModalsLogo=###,'middle','sites'}">
                                                        </if>

                                                    </div>
                                                    <input type="text" id="logo" name="logo" value="" autocomplete="off" style="position: absolute;left:-9999px"/>
                                                </td>
                                            </tr>
                                        <foreach name="modals_cat" item="row">
                                            <tr class="modals_cat">
                                                <td class="td_left">
                                                    <label class='label_width'>
                                                        <input type='checkbox' value='{$row.id}' class="cat_id" name='cat_id[]' autocomplete="off" {$detail.cat_id|getChecked=###,$row[id]}>
                                                        {$row.name}
                                                    </label>
                                                </td>
                                                <td>

                                                    <table>

                                                        <tr>
                                                        <foreach name="row['sub']" item="row2">
                                                            <td>
                                                                <label class='label_width'>
                                                                    <input type='checkbox' value='{$row2.id}' class='cat_sub_id' name='cat_sub_id[]' autocomplete="off" {$detail.cat_sub_id|getChecked=###,$row2[id]}>
                                                                    {$row2.name}
                                                                </label>
                                                            </td>
                                                        </foreach>
                                            </tr>
                                    </table>              
                                    </td>
                                    </tr>
                                    </foreach>
                                    <tr id="tr_cat_sub"> </tr>
                                    <tr id="tr_tags"></tr>
                                    <tr>
                                        <td class="td_left">颜色</td>
                                        <td>
                                    <foreach name="modals_color" item="row">
                                        <label class='label_width'>
                                            <input type='checkbox' value='{$row.id}' name='modal_color_id[]' {$detail.color_id|getChecked=###,$row['id']} autocomplete="off">
                                            {$row.name}
                                        </label>
                                    </foreach>
                                    </td>
                                    </tr>
                                    <tr>
                                        <td class="td_left">布局</td>
                                        <td>
                                    <foreach name="modals_lay" item="row">
                                        <label class='label_width'>
                                            <input type='radio' value='{$row.id}' name='modal_lay_id' {$detail.lay_id|getEqual=###,$row['id'],'checked'} autocomplete="off">
                                            {$row.name}
                                        </label>
                                    </foreach>
                                    </td>
                                    </tr>
                                    <tr>
                                        <td class="td_left">标签:<a onclick="addTags()">+添加标签</a></td>
                                        <td id="td_tags"> 
                                    <foreach name="tags" item="row">
                                        <input name="tag[]" type="text" class="common_txt tag" autocomplete="off" value="{$row}"/><a onclick=$(this).prev('input').remove();
                                                                                                                                     $(this).remove()>删除</a>
                                    </foreach>
                                    </td>
                                    </tr>
                                    <tr id="tr_keywords">
                                        <td class="td_left">关键字:</td>
                                        <td> 
                                            <input name="keywords" id="keywords" type="text" class="common_txt" value="{$detail.keywords}" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="td_left">描述</td>
                                        <td>
                                            <textarea id="description" name="description" rows="8" cols="60">{$detail.description}</textarea>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="td_left">网址来源:</td>
                                        <td>
                                            <input name="source" type="text" id="source" class="common_txt" value="{$detail.source}" />
                                            <a class="btn btn-sm btn-purple" onclick="getSeo()"> 获取SEO </a>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="td_left">排序:</td>
                                        <td>
                                            <input name="ord" type="text" class="common_txt" value="{$detail.ord}" />
                                        </td>
                                    </tr>

                                    <tr>
                                        <td class="td_left"></td>
                                        <td>
                                            <input type='hidden' name='id' value='{$Think.get.id}'/>
                                            <button class="btn btn-info btn-sm" type="submit">
                                                <i class="icon-ok bigger-110 "></i>
                                                保 存
                                            </button>
                                            <button class="btn btn-sm reset" type="button" onclick="goUrl(-1)">
                                                <i class="icon-undo bigger-110"></i>
                                                返 回
                                            </button>
                                            <div class="page_nav clearfix">
                                                <div class="next_page" title="下一篇">
                                                    <notempty name="next">
                                                        下一篇:   <a href="{$next.id}.html">{$next.name}</a>
                                                    </notempty>
                                                </div>
                                                <div class="pre_page" title="上一篇">
                                                    上一篇: <a href="{$prev.id}.html">{$prev.name}</a>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                    </tbody>
                                    </table>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <include file="Public:setting" />
    </div>
</div>
<div class="modal fade" id="modal_cat" data-id="0" data-modal="position"  tabindex="-1" role="dialog" aria-labelledby="modal_catLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" ></h4>
            </div>
            <div class="modal-body">
                名称：
                <input id="cat_name" type="text" class="common_txt" value="{$detail.ord}" maxlength="20" autocomplete="off"/>
            </div>
            <div class="modal-footer">
                <button class="btn btn-danger btn-xs ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="submit" role="button" aria-disabled="false" >
                    <span class="ui-button-text">
                        <i class="icon-trash bigger-110"></i>
                        确 定
                    </span>
                </button>
                <button class="btn btn-xs ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false" data-dismiss="modal">
                    <span class="ui-button-text">
                        <i class="icon-remove bigger-110"></i>
                        取 消
                    </span>
                </button>

            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function() {
        $("#form").validate({
            errorPlacement: function(error, element) {
                var error_td = element.parents('td');
                error_td.find('label.error').hide();
                error_td.append(error);
            },
            rules: {
                name: {
                    required: true
                }
            },
            messages: {
                name: {
                    required: '网址名称不能为空'
                }
            }
        });
        var id = "{$Think.get.id}";
        if (id > 0) {
            var cat_id = "{$detail.cat_id}";
            var color_id = "{$detail.color_id}";
            $("input[name=modal_cat_id][value=" + cat_id + "]").attr("checked", "checked");
        }
        $(".modals_cat").find(".cat_sub_id").click(function() {
            var obj = $(this);
            var length_check = obj.parents(".modals_cat").find(".cat_sub_id:checked").length;
            if (length_check > 0) {


                obj.parents(".modals_cat").find(".cat_id").attr("checked", true)
            } else {
                obj.parents(".modals_cat").find(".cat_id").removeAttr("checked")
            }
        })
    });
    function getSeo() {
        $.post(getUrl("Ajax/getSeo"), {url: $("#source").val()}, function(data) {
            $("#name").val(data.title);
            $("#keywords").val(data.keywords);
            $("#description").val(data.description);
        }, "json")
    }
</script>
<include file="Public:foot" />
<style>
    .descriptions{
        width:420px;
    }
    .defaults{
        width:220px;
    }
    .ui-helper-hidden-accessible{
        display: none
    }
    .tag{width:120px;margin-right: 10px}
</style>
<script type="text/javascript">
    $(function() {
        getTagAutocomplete();
    });
    function getTagAutocomplete() {
        $(".tag").autocomplete({
            source: "__APP__/{$Think.MODULE_NAME}/Ajax/autocomplete/mtype/{$mtype}",
            minLength: 1
        });
    }
    function addTags() {
        var tr = "<input name='tag[]' type='text' class='common_txt tag'  value=''/>\n\
<a onclick=$(this).prev('input').remove();$(this).remove()>删除</a>";
        $('#td_tags').append(tr);
        getTagAutocomplete();
    }
</script>
<include file="Sites:plupload" />